package guda.demox.common.util;

import java.util.*;


public class TransformHelper {

    public static <S, T> List<T> transform(Collection<S> input, Transform<S, T> transformer) {
        List<T> ret = new ArrayList<T>();
        if (input == null) {
            return ret;
        }
        for (S o : input) {
            ret.add(transformer.transform(o));
        }
        return ret;
    }

    public static <S, T> Set<T> transform2Set(Collection<S> input, Transform<S, T> transformer) {
        Set<T> ret = new HashSet<T>();
        if (input == null) {
            return ret;
        }
        for (S o : input) {
            ret.add(transformer.transform(o));
        }
        return ret;
    }

}
